package com.wx.gof.pattern.behavioral.iterator;

import java.util.List;

/**
 * @ClassName CourseIterator
 * @Author wx
 * @Description 课程迭代器
 * @Date 2018-12-12-22:42
 */
public class CourseIterator<E> implements MyIterator<E>{
    private List<E> list;
    private int position;

    public CourseIterator(List<E> list) {
        this.list = list;
        this.position = 0;
    }

    @Override
    public boolean hasNext() {
        return this.position < this.list.size();
    }

    @Override
    public E next() {
        E e = list.get(this.position);
        this.position ++;
        return e;
    }
}
